<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="com.gkwave.module.bean.BranchBean"%>
<%@page import="java.util.List"%>
<%@page import="com.gkwave.module.bean.LocationBean"%>
<%@page import="com.gkwave.module.dao.HealthCareDAO"%>
<%@page import="com.gkwave.module.dao.GymYogaDAO"%>
<%@page import="java.util.Iterator"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>::YOGA::</title>
<script type="text/javascript">
	function submitPage(arg){
		document.forms["yoga"].hidden_1.value=arg;
		document.forms["yoga"].submit();
	}
</script>
</head>
<%
HealthCareDAO dao = new HealthCareDAO();
List<LocationBean> list = dao.getLocationList();
List<BranchBean> branchList = null;
String nmYoga = (String)request.getParameter("nmYoga");
String idCity = (String)request.getParameter("idCity");
String idBranch = (String)request.getParameter("idBranch");
String idEmail = (String)request.getParameter("idEmail");
String nrTotalSeat = (String)request.getParameter("nrTotalSeat");
String nrFee = (String)request.getParameter("nrFee");

String hidden_1 = (String)request.getParameter("hidden_1");
String nmFromSlotTime1 = (String)request.getParameter("nmFromSlotTime1");
String nmToSlotTime1 = (String)request.getParameter("nmToSlotTime1");
String nmFromSlotTime2 = (String)request.getParameter("nmFromSlotTime2");
String nmToSlotTime2 = (String)request.getParameter("nmToSlotTime2");
System.out.println(hidden_1);
Integer id_city = 0;
boolean result = false;
boolean isSubmitted = false;
if(hidden_1!= null && hidden_1.equals("save")){
	GymYogaDAO dao1 = new GymYogaDAO();
	result = dao1.saveGymYogaDetails(2,nmYoga,idBranch,idEmail,nrTotalSeat,nmFromSlotTime1,nmToSlotTime1,nmFromSlotTime2,nmToSlotTime2,nrFee);
	idCity = null;
	if(result){
		isSubmitted = true;
	}
	
}else{
	if(idCity!=null){
		id_city = Integer.parseInt(idCity);
		branchList = dao.getBranchesByLocation(id_city);
	}	
}
%>
<body>
<form name="yoga" action="yoga" method="post">
<input type="hidden" name="hidden_1">
	<table>
		<thead>Yoga Page</thead>
			<%
			if(isSubmitted){
				if(result){
			%>
				<tr align="center">
					<td align="center" colspan="2">Data saved successfully!!!</td>
				</tr>
			<%
				}else{
			%>
				<tr align="center">
					<td align="center" colspan="2">Error...!!!</td>
				</tr>
			<%
				}
			}
			%>		
		<tr>	
			<td>City</td>
			<td>
				<select name="idCity" onchange="submitPage('refresh')">
					<option value="0">--Select--</option>
				<%
					if(list!=null){
						Iterator ite = list.iterator();
						while(ite.hasNext()){
						LocationBean bean = (LocationBean)ite.next();
						Integer id = bean.getIdLocation();
						String name = bean.getNmLocation();
				%>
					<option value='<%=id%>' <% if(id==id_city){%>selected<%} %>><%=name%></option>
				<%
						}
					}
				%>
				</select>
			</td>			
		</tr>
		<tr>	
			<td>Branch</td>
			<td>
				<select name="idBranch">
					<option>--Select--</option>
				<%
					if(branchList!=null){
						Iterator ite = branchList.iterator();
						while(ite.hasNext()){
						BranchBean bean = (BranchBean)ite.next();
						Integer id = bean.getIdBranch();
						String name = bean.getNmBranch();
				%>
					<option value='<%=id%>'><%=name%></option>
				<%
						}
					}
				%>
				</select>
			</td>
		</tr>		
		<tr>
			<td>Yoga Name</td><td><input type="text" name="nmYoga"></td>
		</tr>
		<tr>
			<td>Email</td><td><input type="text" name="idEmail"></td>
		</tr>
		<tr>	
			<td>Total Seat</td><td><input type="text" name="nrTotalSeat" size="2" maxlength="3"></td>
		</tr>
		<tr>	
			<td>Slot 1</td><td> From Time:&nbsp;<input type="text" name="nmFromSlotTime1" size="2">&nbsp;(hh:mm am/pm)&nbsp;&nbsp;To :&nbsp;<input type="text" name="nmToSlotTime1" size="2">&nbsp;(hh:mm am/pm)</td></td>
		</tr>
		<tr>	
			<td>Slot 2</td><td>Time: From&nbsp;<input type="text" name="nmFromSlotTime2" size="2">&nbsp;(hh:mm am/pm)&nbsp;&nbsp;To :&nbsp;<input type="text" name="nmToSlotTime2" size="2">&nbsp;(hh:mm am/pm)</td>
		</tr>		
		<tr>	
			<td>Fee</td><td><input type="text" name="nrFee" size="4"></td>
		</tr>
		<tr>
			<td><input type="submit" onclick="submitPage('save')" value="Save"></td><td><input type="reset" value="Reset"></td>
		</tr>
	</table>
</form>
</body>
</html>